package com.nextgen.mongo.core;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoOperations;

public class MongoInstance {
	private static MongoOperations mongoOperation;

	private MongoInstance() {
	}

	public static MongoOperations getInstance() {
		if (mongoOperation == null) {
			synchronized (MongoInstance.class) {
				if (mongoOperation == null) {
					ApplicationContext ctx = new GenericXmlApplicationContext("MongoDB-config.xml");
					mongoOperation = (MongoOperations)ctx.getBean("mongoTemplate");
				}
			}
		}
		return mongoOperation;
	}

}
